<?php echo $this->fetch('header.html'); ?>    
<?php echo $this->fetch('title.html'); ?>
<div class="category_index clearfix">
<div class="left">
	<ul>
		<?php $_from = $this->_var['gcategorys']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'gcategory');$this->_foreach['fe_gcate'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_gcate']['total'] > 0):
    foreach ($_from AS $this->_var['gcategory']):
        $this->_foreach['fe_gcate']['iteration']++;
?>
		<li data-id="<?php echo $this->_var['gcategory']['id']; ?>"><a id="cate_parent_<?php echo $this->_var['gcategory']['id']; ?>" <?php if ($this->_var['gcategory']['no_children']): ?>href="index.php?app=search&cate_id=<?php echo $this->_var['gcategory']['id']; ?>"<?php else: ?>href="javascript:void(0)" <?php if (($this->_foreach['fe_gcate']['iteration'] <= 1)): ?>class="cur"<?php endif; ?> onclick="show_child(<?php echo $this->_var['gcategory']['id']; ?>)"<?php endif; ?>><?php echo htmlspecialchars($this->_var['gcategory']['value']); ?></a></li>
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                <div class="li_wrap"></div>
	</ul>
</div>
<div class="right">
<?php $_from = $this->_var['gcategorys']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'gcategory');$this->_foreach['fe_gcate'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_gcate']['total'] > 0):
    foreach ($_from AS $this->_var['gcategory']):
        $this->_foreach['fe_gcate']['iteration']++;
?>
<div id="cate_son_<?php echo $this->_var['gcategory']['id']; ?>" class="cate_son" <?php if (! ($this->_foreach['fe_gcate']['iteration'] <= 1)): ?>style="display:none"<?php endif; ?>>
	<?php $_from = $this->_var['gcategory']['children']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'child1');if (count($_from)):
    foreach ($_from AS $this->_var['child1']):
?>
        <div class="cate_son_wrap">
	<a href="index.php?app=search&cate_id=<?php echo $this->_var['child1']['id']; ?>"><h4><?php echo htmlspecialchars($this->_var['child1']['value']); ?></h4></a>
	<ul>
		<?php $_from = $this->_var['child1']['children']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'child2');if (count($_from)):
    foreach ($_from AS $this->_var['child2']):
?>
                <li>
		<a href="index.php?app=search&cate_id=<?php echo $this->_var['child2']['id']; ?>">
		<div class="img_wrap"><p class="img"><img src="<?php echo $this->_var['site_url']; ?>/<?php echo htmlspecialchars($this->_var['child2']['cate_logo']); ?>"></p></div>
		<p class="title"><?php echo htmlspecialchars($this->_var['child2']['value']); ?></p>
		</a>
                    </li>
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
	</ul>
        </div>
	<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
</div>
<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
</div>
</div>
<script>
    var cate_top=new Array();
    $(function(){
        $(".category_index .left ul li").each(function(){
            var id=$(this).attr('data-id');
            cate_top[id]=$(this).offset().top-43;
        });
    })
    function show_child(id){
        //var cate_top = $('#cate_parent_'+id).offset().top-43;
        $(".category_index .left ul").animate({scrollTop: cate_top[id]},300);
        $(".category_index .left ul li a").removeClass('cur');
        $('#cate_parent_'+id).addClass('cur');
        
        $(".cate_son").hide();
        $("#cate_son_"+id).show();
    }
</script>
<?php echo $this->fetch('footer.html'); ?>